

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYCATEGORY')
            and   name  = 'Index_parentId'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYCATEGORY.Index_parentId
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYCATEGORY')
            and   name  = 'Index_vstatus'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYCATEGORY.Index_vstatus
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYDETAIL')
            and   name  = 'Index_INVENTORYCATEGORYID'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYDETAIL.Index_INVENTORYCATEGORYID
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYDETAIL')
            and   name  = 'Index_fixedasset'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYDETAIL.Index_fixedasset
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYDETAIL')
            and   name  = 'Index_mainfacility'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYDETAIL.Index_mainfacility
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYDETAIL')
            and   name  = 'Index_vstatus'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYDETAIL.Index_vstatus
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYORDER')
            and   name  = 'Index_inventorydetail'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYORDER.Index_inventorydetail
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYORDER')
            and   name  = 'Index_unit'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYORDER.Index_unit
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('T_MATERIAL_FACILITYINVENTORYORDER')
            and   name  = 'Index_vstatus'
            and   indid > 0
            and   indid < 255)
   drop index T_MATERIAL_FACILITYINVENTORYORDER.Index_vstatus
go

if exists (select 1
            from  sysobjects
           where  id = object_id('T_MATERIAL_FACILITYINVENTORYCATEGORY')
            and   type = 'U')
   drop table T_MATERIAL_FACILITYINVENTORYCATEGORY
go

if exists (select 1
            from  sysobjects
           where  id = object_id('T_MATERIAL_FACILITYINVENTORYDETAIL')
            and   type = 'U')
   drop table T_MATERIAL_FACILITYINVENTORYDETAIL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('T_MATERIAL_FACILITYINVENTORYORDER')
            and   type = 'U')
   drop table T_MATERIAL_FACILITYINVENTORYORDER
go

/*==============================================================*/
/* User: dbo                                                    */
/*==============================================================*/

/*==============================================================*/
/* Table: T_MATERIAL_FACILITYINVENTORYCATEGORY                  */
/*==============================================================*/
create table T_MATERIAL_FACILITYINVENTORYCATEGORY (
   ID                   bigint               not null,
   NAME                 varchar(64)          not null,
   PARENT_ID            bigint               null,
   CODE                 varchar(64)          null default '0000',
   LEAF_FLAG            char(1)              null,
   CODE_ALL             varchar(64)          null,
   CODE_PARENT          varchar(64)          null,
   DESCRIPTION          varchar(512)         null,
   PRIORITY             tinyint              not null,
   VSTATUS              tinyint              not null,
   VERSION              int                  not null,
   REFS                 varchar(1024)        null,
   CREATOR              varchar(64)          null,
   CREATE_TIME          bigint               null,
   LAST_MODIFIED        bigint               null,
   LAST_MODIFIER        varchar(64)          null,
   constraint PK_T_FACILITYINVENTORYCATEGORY primary key nonclustered (ID)
)
go

/*==============================================================*/
/* Index: Index_parentId                                        */
/*==============================================================*/
create index Index_parentId on T_MATERIAL_FACILITYINVENTORYCATEGORY (
PARENT_ID ASC
)
go

/*==============================================================*/
/* Index: Index_vstatus                                         */
/*==============================================================*/
create index Index_vstatus on T_MATERIAL_FACILITYINVENTORYCATEGORY (
VSTATUS ASC
)
go

/*==============================================================*/
/* Table: T_MATERIAL_FACILITYINVENTORYDETAIL                    */
/*==============================================================*/
create table T_MATERIAL_FACILITYINVENTORYDETAIL (
   ID                   bigint               not null,
   NAME                 varchar(64)          not null,
   INVENTORYCATEGORY_ID bigint               null,
   SPECIFICATIONMODEl   varchar(512)         null,
   MEASUREUNIT_ID       int                  null,
   SUPPLIER_ID          bigint               null,
   FACILITYCATEGORY_ID  int                  null,
   SPECIALITY_ID        int                  null,
   IS_MAINFACILITY      char(1)              null,
   BELONGSTO_ID         bigint               null,
   PRIORITY             tinyint              not null,
   DESCRIPTION          varchar(512)         null,
   MANUFACTURER         VARCHAR(128)         null,
   ORIGIN               VARCHAR(64)          null,
   AZSYBW               VARCHAR(128)         null,
   CODE_ALL             varchar(64)          null,
   CODE_PARENT          varchar(64)          null,
   KKS                  varchar(32)          null,
   IS_NEED_INSTALL      char(1)              null,
   PROJECT_ID           bigint               null,
   CODE                 varchar(32)          null,
   FIXEDASSETCATEGORY_ID bigint               null,
   VSTATUS              tinyint              not null,
   VERSION              int                  not null,
   CREATE_TIME          bigint               null,
   CREATOR              varchar(64)          null,
   LAST_MODIFIED        bigint               null,
   LAST_MODIFIER        varchar(64)          null,
   REFS                 varchar(1024)        null,
   constraint PK_T_FACILITYINVENTORYDETAIL primary key nonclustered (ID)
)
go

/*==============================================================*/
/* Index: Index_INVENTORYCATEGORYID                             */
/*==============================================================*/
create index Index_INVENTORYCATEGORYID on T_MATERIAL_FACILITYINVENTORYDETAIL (
INVENTORYCATEGORY_ID ASC
)
go

/*==============================================================*/
/* Index: Index_mainfacility                                    */
/*==============================================================*/
create index Index_mainfacility on T_MATERIAL_FACILITYINVENTORYDETAIL (
IS_MAINFACILITY ASC,
BELONGSTO_ID ASC
)
go

/*==============================================================*/
/* Index: Index_fixedasset                                      */
/*==============================================================*/
create index Index_fixedasset on T_MATERIAL_FACILITYINVENTORYDETAIL (
FIXEDASSETCATEGORY_ID ASC
)
go

/*==============================================================*/
/* Index: Index_vstatus                                         */
/*==============================================================*/
create index Index_vstatus on T_MATERIAL_FACILITYINVENTORYDETAIL (
VSTATUS ASC
)
go

/*==============================================================*/
/* Table: T_MATERIAL_FACILITYINVENTORYORDER                     */
/*==============================================================*/
create table T_MATERIAL_FACILITYINVENTORYORDER (
   ID                   bigint               not null,
   NAME                 varchar(64)          not null,
   INVENTORYDETAIL_ID   bigint               null,
   UNIT_ID              int                  null,
   QUANTITY             decimal(20,4)        null,
   PRIORITY             tinyint              not null,
   VSTATUS              tinyint              not null,
   VERSION              int                  not null,
   CREATE_TIME          bigint               null,
   CREATOR              varchar(64)          null,
   LAST_MODIFIED        bigint               null,
   LAST_MODIFIER        varchar(64)          null,
   DESCRIPTION          varchar(512)         null,
   constraint PK_T_FACILITYINVENTORYORDER primary key nonclustered (ID)
)
go

/*==============================================================*/
/* Index: Index_inventorydetail                                 */
/*==============================================================*/
create index Index_inventorydetail on T_MATERIAL_FACILITYINVENTORYORDER (
INVENTORYDETAIL_ID ASC
)
go

/*==============================================================*/
/* Index: Index_unit                                            */
/*==============================================================*/
create index Index_unit on T_MATERIAL_FACILITYINVENTORYORDER (
UNIT_ID ASC
)
go

/*==============================================================*/
/* Index: Index_vstatus                                         */
/*==============================================================*/
create index Index_vstatus on T_MATERIAL_FACILITYINVENTORYORDER (
VSTATUS ASC
)
go
